package com.bmuschko.gradle.docker.tasks.network

import com.bmuschko.gradle.docker.tasks.AbstractDockerRemoteApiTask
import groovy.transform.CompileStatic
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.Input

import java.util.concurrent.Callable

@CompileStatic
abstract class DockerExistingNetwork extends AbstractDockerRemoteApiTask {
    /**
     * The ID or name of the network to perform the operation on. The network for the provided ID has to be created first.
     */
    @Input
    final Property<String> networkId = project.objects.property(String)

    /**
     * Sets the target network ID or name.
     *
     * @param networkId Network ID or name
     * @see #targetNetworkId(Callable)
     * @see #targetNetworkId(Provider)
     */
    void targetNetworkId(String networkId) {
        this.networkId.set(networkId)
    }

    /**
     * Sets the target network ID or name.
     *
     * @param networkId Network ID or name as Callable
     * @see #targetNetworkId(String)
     * @see #targetNetworkId(Provider)
     */
    void targetNetworkId(Callable<String> networkId) {
        targetNetworkId(project.provider(networkId))
    }

    /**
     * Sets the target network ID or name.
     *
     * @param networkId Network ID or name as Provider
     * @see #targetNetworkId(String)
     * @see #targetNetworkId(Callable)
     */
    void targetNetworkId(Provider<String> networkId) {
        this.networkId.set(networkId)
    }
}
